package model.minimax;

import model.Slot;

/**
 * Represents a possible ladder pattern.
 */
public class LadderPattern
{
    private Slot[] slots;
    private boolean isLeftLadder;

    public LadderPattern(boolean isLeftLadder, Slot slot0, Slot slot1, Slot slot2, Slot slot3, Slot slot4)
    {
        super();
        this.isLeftLadder = isLeftLadder;

        this.slots = new Slot[5];
        this.slots[0] = slot0;
        this.slots[1] = slot1;
        this.slots[2] = slot2;
        this.slots[3] = slot3;
        this.slots[4] = slot4;
    }

    public Slot[] getSlots()
    {
        return slots;
    }

    /**
     * @return true if the ladder is a left ladder, false otherwise
     */
    public boolean isLeftLadder()
    {
        return isLeftLadder;
    }

    /**
     * Returns the Slots that can potentially neutralize this ladderPattern. (or
     * null if the ladder pattern can't be neutralized.)
     * 
     * @return
     */
    public Slot[] getNeutralizingSlots()
    {
        if (this.slots[0].getRowIndex() == 0)
        {
            return null;
        }
        else if (this.isLeftLadder)
        {
            return this.slots[2].getUpperRightAndLowerLeftAdjacentSlots();
        }
        else
        {
            return this.slots[3].getUpperLeftAndLowerRightAdjacentSlots();
        }
    }
}
